home *** CD-ROM | disk | FTP | other *** search
- // Fill input stream buffer
- int gpibin::underflow()
- {
- int count,growth,inplimit;
- char *temp;
-
- // See if we have allocated a stream buffer yet
- if(base_ == NULL)
- {
- gleng_ = 128; // a good starting length
- base_ = new char[gleng_];
- if(base_ == NULL)
- {
- cerr << "Can't allocate get stream buffer." << endl;
- exit(1);
- }
- ebuf_ = base_ + gleng_;
- }
- inplimit = gleng_-1;
- // Get entire gpib transfer
- for(count=0;;)
- {
- ::ibrd(device,base_+count,inplimit);
- status = ibsta; // ibsta & ibcnt are NI globals
- count += ibcnt;
- if(status & (ERR|TIMO|END)) // Done if EOI or error
- break;
- growth = gleng_ >> 1;
- temp = new char[gleng_ + growth];
- if(temp == NULL)
- {
- cerr << "Can't increase get stream size." << endl;
- exit(1);
- }
- // transfer to new area & release old area
- memmove(temp,base_,gleng_);
- delete base_;
- base_ = temp;
- inplimit = growth-1;
- gleng_ += growth;
- }
- base_[count] = '\0';
- if(base_[count-1] == '\n')
- base_[--count] = '\0';
- gptr_ = base_;
- egptr_ = base_ + count; // Set pointer to end of get portion
-
-
- return *gptr_;
- }
-
-